/**************************
Syntax to perform the analyses reported in Tables OA8-OA10
*****************************/

clear
cd "C:\Users\Joshua\OneDrive\Documents\Work - Finished\BJPS - Comp Explanations\Dataverse"
use "combined_experiments.dta"

label var eval "Evaluation"

label def tr 1 "No Justification" 2 "Justification" 3 "Justification w/Counter"
label values treat tr
label def tr1 1 "No Justification" 2 "Justification" 3 "High Credibility" 4 "Low Credibility"
label values treat2 treat3 tr1

encode study, gen(exp)

label def cop 1 "Co-Partisan" 2 "Opposing Partisan" 3 "Independent"
label values copartisan cop

eststo clear
*Hypotheses 1 & 2
eststo: regress eval ib2.treat i.exp, vce(cluster id_1)

*Hypothesis 3 (Truncated Treat)
eststo: regress eval ib2.treat2 i.exp, vce(cluster id_1)
		margins, dydx(3.treat2 4.treat2) post coeflegend
		test _b[3.treat2] = _b[4.treat2]
		lincom _b[3.treat2] - _b[4.treat2]
		
*Hypothesis 4 (Full Treat)
eststo: regress eval ib2.treat3 i.exp, vce(cluster id_1)
		margins, dydx(3.treat3 4.treat3) post coeflegend
		test _b[3.treat3] = _b[4.treat3]
		lincom _b[3.treat3] - _b[4.treat3]
	
esttab using "table_oa8.rtf", replace onecell label se star(+ 0.1 * 0.05 ** 0.01) ///
	mtitles("Hyp 1 & 2" "Hyp 3, Exp 1 & 2" "Hyp 3, All Exp") ///
	title("{\b Table OA8}: Combining the Experiments H1-H3") ///
	nobaselevels 

******Interaction
eststo clear
eststo: regress eval ib2.treat2##i.copartisan i.exp, vce(cluster id_1)
eststo: regress eval ib2.treat3##i.copartisan i.exp, vce(cluster id_1)

esttab using "table_oa9.rtf", replace onecell label se star(+ 0.1 * 0.05 ** 0.01) ///
	mtitles("Exp 1 & 2" "All Exp") ///
	title("{\b Table OA9}: Combining the Experiments H4") ///
	nobaselevels 
		
	margins, dydx(3.treat2 4.treat2) at(copartisan==(1 2)) coeflegend post
		
*Marginal effects
regress eval ib2.treat2##i.copartisan i.exp, vce(cluster id_1)
	margins, dydx(3.treat2 4.treat2) at(copartisan==(1 2)) post
	estimates store m1
regress eval ib2.treat3##i.copartisan i.exp, vce(cluster id_1)
	margins, dydx(3.treat3 4.treat3) at(copartisan==(1 2)) post
	estimates store m2
	
esttab m1 m2 using "table_oa10.rtf", mtitles ci nobaselevels star(+ 0.10 * 0.05 ** 0.01) onecell replace 


*** Differences: added manually to the table

regress eval ib2.treat2##i.copartisan i.exp, vce(cluster id_1)
	margins, dydx(3.treat2 4.treat2) at(copartisan==(1 2)) post coeflegend

	*Co-Partisan
	test _b[3.treat2:1bn._at] = _b[4.treat2:1bn._at]
	lincom _b[3.treat2:1bn._at] - _b[4.treat2:1bn._at]
	*Opposing Partisan
	lincom _b[3.treat2:2._at] - _b[4.treat2:2._at]
	test _b[3.treat2:2._at] = _b[4.treat2:2._at] 
	*Diff in Diff
	mlincom (1-3) - (2-4), all
	
regress eval ib2.treat3##i.copartisan i.exp, vce(cluster id_1)
	margins, dydx(3.treat3 4.treat3) at(copartisan==(1 2)) post
*Co-Partisan
	test _b[3.treat3:1bn._at] = _b[4.treat3:1bn._at]
	lincom _b[3.treat3:1bn._at] - _b[4.treat3:1bn._at]
	*Opposing Partisan
	lincom _b[3.treat3:2._at] - _b[4.treat3:2._at]
	test _b[3.treat3:2._at] = _b[4.treat3:2._at] 
	*Diff in Diff
	mlincom (1-3) - (2-4), all

